<template>
  <el-dialog :title="title || '请选择'" :visible.sync="visible" :width="dialogWidth || '500px'" append-to-body>
    <el-radio-group v-model="selected">
      <el-radio v-for="item in options" :label="item.value" :key="item.value">{{ item.label }}</el-radio>
    </el-radio-group>

    <span slot="footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="handleConfirm">确认</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    options: {
      type: Array,
      default: () => []
    },
    title: {},
    dialogWidth: {}
  },
  data() {
    return {
      visible: false,
      selected: ''
    };
  },
  methods: {
    show() {
      this.visible = true
      this.selected = this.options[0] && this.options[0].value
    },
    handleConfirm() {
      this.visible = false
      this.$emit('confirm', this.selected)
    },
    setSelected(value) {
      this.selected = value
    }
  }
};
</script>
<style lang="scss" scoped>

</style>